#include <string.h>
#include <iostream>
using std::cout;
using std::endl;
class Computer{
public:
    Computer(const char * brand, float price)
    :_brand(new char[strlen(brand) + 1]())
    ,_price(price)
    {
        strcpy(_brand ,brand);
    }

    ~Computer(){
        if(_brand){
            delete [] _brand;
            _brand = nullptr;
        }
    }

    void print(){
        cout << "_brand=" << _brand << ",_price=" << _price << endl;
    }


private:
    char * _brand;
    float _price;
};


void test(){
    Computer * pc = new Computer("Apple", 8700);
    //使用pc指针调用Computer里面的print成员函数
    //指针使用：箭头访问运算符、解引用运算符
    pc->print();
    (*pc).print();

    delete pc;
    pc = nullptr;
}

int main()
{
    test();
    return 0;
}

